using System;
using System.Web.Mvc;
using System.Linq;

using MvcCmsWiki.Service;
using MvcCms.Data.Entities;
using MvcCms.Data.Pagination;
using MvcCms.Service.Logging;

namespace MvcCmsWikiPlex.Controllers
{
    public class WikiPlexAjaxController : MvcCms.Service.Code.BaseClasses.MvcCmsControllerBase
    {
        #region Constructors
        private readonly IWikiService _wikiService;

        public WikiPlexAjaxController(IWikiService wikiService)
        {
            _wikiService = wikiService;
        }

        #endregion

        public JsonResult GetHistory(int id, string slug)
        {
            try
            {
                var history = _wikiService.GetDTOHistory(slug, id, 10).ToList();
                return Json(history);
            }
            catch (Exception ex)
            {
                AppLogging.GetLogger().Error(ex.Message, ex);
                return Json(new { error = ex.Message });
            }
        }

    }
}
